import { Select, SelectProps } from "antd";
import React from "react";

interface Enum {
    value: string
    label: string
}

interface Props extends SelectProps<string | number> {
    options: Array<Enum>
    keyName: string
    labelFormat?: (val: string) => string
}

const FormSelect: React.FC<Props> = ({ value, options, keyName, labelFormat, disabled, onChange }) => {
    return <Select disabled={disabled} value={value} onChange={onChange}>
        {
            options.map((item, index) => {
                return <Select.Option key={`${keyName}_Option_${index}`} value={item.value}>{labelFormat ? labelFormat(item.label) : item.label}</Select.Option>
            })
        }
    </Select>
}


export default FormSelect